package 数据结构.章节09._146_单链表;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * @author 挚爱之夕
 * @date 2021/10/8 - 10 - 08 - 17:03
 * @Description: 数据结构.章节09._146_单链表
 * @Version: 1.0
 */

/**
 * 测试类
 */
public class SingleLinkedListTest {
    SingleLinkedList<Object> list = new SingleLinkedList<Object>();
    @Test
    @Before
    public void add() {
        list.add("a");
        list.add("b");
        list.add("c");
//        System.out.println(list.toString());
    }

    @Test
    public void delete() {
        list.delete(0);
//        System.out.println(list.toString());
        //断言预期与实际相同,测试类不建议写输出
        Assert.assertEquals("b -> c",list.toString());
    }

    @Test
    public void testDelete() {
        list.delete("a");
        Assert.assertEquals("b -> c",list.toString());
    }

    @Test
    public void modify() {
        list.modify(0,"love");
        Assert.assertEquals("love -> b -> c",list.toString());
    }

    @Test
    public void contains() {
        Assert.assertTrue(list.contains("a"));
    }

    @Test
    public void find() {
        int i = list.find("b");
        Assert.assertEquals(1,i);
    }

    @Test
    public void testFind() {
        Object i = list.find(0);
        Assert.assertEquals("a",i);
    }

    @Test
    public void testToString() {
        Assert.assertEquals("a -> b -> c",list.toString());
    }
}